const path = require('path')
const glob = require('glob')
function resolve (dir) {
	return path.join(__dirname, dir)
}
function entrys () {
	const views = resolve('src/views')
	let entrys
	entrys = glob.sync(views + '/**/**/entry.js')
	const maps = {}
	entrys.forEach((v) => {
		const name = path.dirname(path.relative(views, v))
		maps[name] = v
	})
	return maps
}

module.exports = {
	publicPath: './',
	pages: entrys(),
	parallel: false,
	configureWebpack: {
		resolve: {
			alias: {
				'@': '/src'
			}
		}
	},
	chainWebpack: (config) => {
		config.module.rule('md').test(/\.md/).use('vue-loader').loader('vue-loader').end().use('vue-markdown-loader').loader('vue-markdown-loader/lib/markdown-compiler').options({
			raw: true
		})
	}
}
